/*
 * Copyright (C) 2015 The Gravitee team (http://gravitee.io)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import { BaseHarnessFilters, ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';
import { MatSelectHarness } from '@angular/material/select/testing';

import { Qos } from '../../../../entities/management-api-v2';

export class GioFormQosHarness extends ComponentHarness {
  public static hostSelector = 'gio-form-qos';

  /**
   * Get Harness with the given filter.
   *
   * @param options Options for filtering which input instances are considered a match.
   * @return a `HarnessPredicate` configured with the given options.
   */
  public static with(options: BaseHarnessFilters = {}): HarnessPredicate<GioFormQosHarness> {
    return new HarnessPredicate(GioFormQosHarness, options);
  }

  async getSelectedQos() {
    const qosSelect = await this.locatorFor(MatSelectHarness)();
    return qosSelect.getValueText();
  }

  async selectOption(qos: Qos) {
    const qosSelect = await this.locatorFor(MatSelectHarness)();
    return qosSelect.clickOptions({ text: qos });
  }
}
